package com.example.thirdhomework

import android.app.Activity
import android.content.Intent
import android.graphics.Bitmap
import android.os.Bundle
import android.provider.MediaStore
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {
    private lateinit var resultTextView: TextView
    private val REQUEST_IMAGE_CAPTURE = 1
    private val REQUEST_CODE_SECOND_ACTIVITY = 2

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        resultTextView = findViewById(R.id.resultTextView)

        // 启动第1个二级Activity并传参
        findViewById<Button>(R.id.button1).setOnClickListener {
            val intent = Intent(this, FirstActivity::class.java)
            intent.putExtra("message", getString(R.string.message_to_first_activity))
            startActivity(intent)
        }

        // 启动第2个二级Activity并返回数据
        findViewById<Button>(R.id.button2).setOnClickListener {
            val intent = Intent(this, SecondActivity::class.java)
            startActivityForResult(intent, REQUEST_CODE_SECOND_ACTIVITY)
        }

        // 启动第3个二级Activity并调用系统相机
        findViewById<Button>(R.id.button3).setOnClickListener {
            val intent = Intent(this, ThirdActivity::class.java)
            startActivity(intent)
        }

        // 启动第4个二级Activity并实现计时功能
        findViewById<Button>(R.id.button4).setOnClickListener {
            val intent = Intent(this, FourthActivity::class.java)
            startActivity(intent)
        }
    }


}
